package com.tgpms.common;

import lombok.Data;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author May
 * <p>
 * 返回结果集
 */
@Data
@ApiModel(value="接口返回对象", description="接口返回对象")
public class Result<T> implements Serializable {

    /**
     * 标识符
     */
    private static final long serialVersionUID = -7319737625485900657L;

    /**
     * 默认返回状态
     */
    @ApiModelProperty(value = "成功标志")
    private Boolean success = true;

    /**
     * 默认返回消息提醒
     */
    @ApiModelProperty(value = "返回处理消息")
    private String msg = "操作成功";

    /**
     * 返回数据
     */
    @ApiModelProperty(value = "返回数据对象")
    private T data;
    
    //操作成功返回
    public static<T> Result<T> OK(String msg,T data){
    	Result<T> r = new Result<T>();
		r.setSuccess(true);
		r.setMsg(msg);
		r.setData(data);
		return r;
    }
    
    //操作成功返回
    public static<T> Result<T> OK(String msg){
    	Result<T> r = new Result<T>();
		r.setSuccess(true);
		r.setMsg(msg);
		return r;
    }
    
    
    //操作失败返回
    public static<T> Result<T> ERROR(String msg){
    	Result<T> r = new Result<T>();
		r.setSuccess(false);
		r.setMsg(msg);
		return r;
    }
}
